<template>
	<view class="p-10">
		<view class="card" v-if="isShow">
			<u-cell-group>
				<u-cell :title="item.title" :value="superData?.[item.prop]" v-for="(item, index) in data1"></u-cell>
			</u-cell-group>
		</view>
		<view class="card" v-if="isShow1">
			<u-cell-group>
				<u-cell :title="item.title" :value="superData?.[item.prop]" v-for="(item, index) in data2"></u-cell>
			</u-cell-group>
		</view>
		<view class="card" v-if="isShow2">
			<u-cell-group>
				<u-cell :title="item.title" :value="superData?.[item.prop]" v-for="(item, index) in data3"></u-cell>
			</u-cell-group>
		</view>
		<view class="card">
			<u-cell-group>
				<u-cell :title="item.title" :value="options[item.prop]" v-for="(item, index) in data"></u-cell>
				<up-cell title="现场图片" v-if="options.filePaths?.length">
					<template #value>
						<up-image :show-loading="true" :src="url" width="80px" height="80px"></up-image>
					</template>
				</up-cell>
			</u-cell-group>
			<view class="flex m-t-10" v-if="isIf !== 1">
				<u-button style="width: 200rpx" type="primary" shape="circle" text="编辑督办" @click="click"></u-button>
			</view>
		</view>
	</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { infoHiddenDanger } from '@/api/hidden-danger.js';
import { apiBaseURL } from '@/config/index.js';

let isShow = ref(),
	isShow1 = ref(),
	isShow2 = ref();

let superData = ref();

let options = ref({}),
	data = ref([
		{
			title: '上报日期',
			prop: 'checkDate'
		},
		{
			title: '上报人',
			prop: 'createBy'
		},
		{
			title: '所属部门',
			prop: 'deptName'
		},
		{
			title: '风险点',
			prop: 'riskLocationName'
		},
		{
			title: '隐患成因',
			prop: 'hiddenDangerFactorName'
		},
		{
			title: '隐患等级',
			prop: 'hiddenLevelName'
		},
		{
			title: '责任单位',
			prop: 'dutyDeptName'
		},
		{
			title: '责任人',
			prop: 'dutyUserName'
		},
		{
			title: '问题描述',
			prop: 'hiddenDangerInfo'
		},
		{
			title: '整改方式',
			prop: 'changeTypeName'
		},
		{
			title: '整改措施',
			prop: 'changeInfo'
		}
	]),
	data1 = ref([
		{
			title: '一级督办人',
			prop: 'oneSupervisionUserName'
		},
		{
			title: '督办日期',
			prop: 'oneEndDate'
		},
		{
			title: '督办意见',
			prop: 'oneMessage'
		},
		{
			title: '下级提级督办时间',
			prop: 'oneApplyDate'
		}
	]),
	data2 = ref([
		{
			title: '二级督办人',
			prop: 'twoSupervisionUserName'
		},
		{
			title: '督办日期',
			prop: 'twoEndDate'
		},
		{
			title: '督办意见',
			prop: 'twoMessage'
		},
		{
			title: '下级提级督办时间',
			prop: 'twoApplyDate'
		}
	]),
	data3 = ref([
		{
			title: '三级督办人',
			prop: 'threeSupervisionUserName'
		},
		{
			title: '督办日期',
			prop: 'threeEndDate'
		},
		{
			title: '督办意见',
			prop: 'threeMessage'
		},
		{
			title: '下级提级督办时间',
			prop: 'threeApplyDate'
		}
	]);

let url = ref();
let isIf = ref();
let datas = ref();
onLoad((e) => {
	let data = JSON.parse(e.data);
	if (data.type == 3) {
		isShow.value = true;
		isShow1.value = true;
		isShow2.value = true;
	} else {
		isShow2.value = false;
		if (data.type == 2) {
			isShow.value = true;
			isShow1.value = true;
		} else {
			isShow1.value = false;
			if (data.type == 1) {
				isShow.value = true;
			}
		}
	}
	datas.value = e.data;
	isIf.value = JSON.parse(e.data)?.state;
	infoHiddenDanger({
		id: JSON.parse(e.data)?.checkPlanId
	}).then((res) => {
		options.value = res.data;
		superData.value = res.data?.supervision;
		res.data?.filePaths && res.data.filePaths.length ? (url.value = apiBaseURL + '/rdfile/download/' + res.data.filePaths[0]?.storageUrl) : '';
	});
});
// 编辑督办
const click = () => {
	uni.navigateTo({
		url: '/pages/professional/hiddenTrouble/supervise/idea?data=' + datas.value
	});
};
</script>
<style scoped>
:deep(.u-cell__title) {
	width: 180rpx !important;
}
</style>
